<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"
          integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">

    <!-- Option 1: Bootstrap Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/js/bootstrap.bundle.min.js"
            integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"
            crossorigin="anonymous"></script>

    <!--    <link href="css/main.css" rel="stylesheet">-->
    <link href="css/product.css" rel="stylesheet">

    <title>奶茶店后台</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light shadow-sm">
    <div class="container-fluid">
        <a class="navbar-brand" href="/main.html">奶茶店后台</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
                aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" href="/order.html">订单管理</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/users.html">用户管理</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="/product.html">商品管理</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/productSort.html">商品分类管理</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/activity.html">活动管理</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/userInfo.html">个人中心</a>
                </li>
            </ul>
        </div>
    </div>
</nav>
<div class="d-flex flex-column align-items-center">

    <div class="alert alert-primary position-absolute w-25 text-center" role="alert" id="alert"
         style="top: 100px; z-index: 1055;" hidden>
    </div>

    <div class="title-holder w-75 mt-lg-3 mb-lg-4 p-lg-5">
        <h1>商品详情</h1>
    </div>

    <div class="d-flex flex-row align-items-baseline">
        <button type="button" class="btn btn-outline-primary me-lg-5" data-bs-toggle="modal"
                data-bs-target="#exampleModal">新建商品
        </button>

        <div class="d-flex flex-row align-items-baseline">
            <select class="form-select mb-lg-3 me-3" aria-label="Default select example" id="selector">
                <option value="1">批量删除</option>
                <!--                <option value="2">批量修改</option>-->
            </select>
            <button type="button" class="btn btn-outline-primary" onclick="productOpera()">确认</button>
        </div>
    </div>


    <table class="table table-striped w-75">
        <thead>
        <tr>
            <th scope="col">#</th>
            <th scope="col" style="width: 100px">商品编号</th>
            <th scope="col" style="width: 160px">商品名</th>
            <th scope="col" style="width: 200px">所属分类</th>
            <th scope="col">中杯价格</th>
            <th scope="col">大杯价格</th>
            <th scope="col">折扣</th>
            <th scope="col" style="width: 270px">商品操作</th>
        </tr>
        </thead>
        <tbody id="table-body">
        <tr>
            <td>
                <div class="form-check">
                    <input class="form-check-input" type="checkbox" value="">
                </div>
            </td>
            <th scope="row">1</th>
            <td>
                <label class="w-75">
                    <input type="text" class="form-control" placeholder="Otto">
                </label>
            </td>
            <td>
                <select class="form-select me-3" aria-label="Default select example">
                    <option value="1">sort #1</option>
                    <option value="2">sort #2</option>
                </select>
            </td>
            <td>
                <label class="w-50">
                    <input type="text" class="form-control" placeholder="Otto">
                </label>
            </td>
            <td>
                <label class="w-50">
                    <input type="text" class="form-control" placeholder="Otto">
                </label>
            </td>
            <td>
                <label class="w-50">
                    <input type="text" class="form-control" placeholder="Otto">
                </label>
            </td>
            <td class="d-flex flex-row align-items-baseline mb-0">
                <button type="button" class="btn btn-primary me-3">修改</button>
                <button type="button" class="btn btn-info me-3" data-bs-toggle="modal"
                        data-bs-target="#productPreviewModal" data-bs-index="` + i + `">预览图
                </button>
                <button type="button" class="btn btn-danger">删除</button>
            </td>
        </tr>
        <tr>
            <td>
                <div class="form-check">
                    <input class="form-check-input" type="checkbox" value="">
                </div>
            </td>
            <th scope="row">2</th>
            <td>
                <label class="w-75">
                    <input type="text" class="form-control" placeholder="Otto">
                </label>
            </td>
            <td>
                <select class="form-select me-3" aria-label="Default select example">
                    <option value="1">sort #1</option>
                    <option value="2">sort #2</option>
                </select>
            </td>
            <td>
                <label class="w-50">
                    <input type="text" class="form-control" placeholder="Otto">
                </label>
            </td>
            <td>
                <label class="w-50">
                    <input type="text" class="form-control" placeholder="Otto">
                </label>
            </td>
            <td>
                <label class="w-50">
                    <input type="text" class="form-control" placeholder="Otto">
                </label>
            </td>
            <td class="d-flex flex-row align-items-baseline">
                <button type="button" class="btn btn-primary me-3">修改</button>
                <button type="button" class="btn btn-info me-3" data-bs-toggle="modal"
                        data-bs-target="#productPreviewModal">预览图
                </button>
                <button type="button" class="btn btn-danger">删除</button>
            </td>
        </tr>
        <tr>
            <td>
                <div class="form-check">
                    <input class="form-check-input" type="checkbox" value="">
                </div>
            </td>
            <th scope="row">3</th>
            <td>
                <label class="w-75">
                    <input type="text" class="form-control" placeholder="Otto">
                </label>
            </td>
            <td>
                <select class="form-select me-3" aria-label="Default select example">
                    <option value="1">sort #1</option>
                    <option value="2">sort #2</option>
                </select>
            </td>
            <td>
                <label class="w-50">
                    <input type="text" class="form-control" placeholder="Otto">
                </label>
            </td>
            <td>
                <label class="w-50">
                    <input type="text" class="form-control" placeholder="Otto">
                </label>
            </td>
            <td>
                <label class="w-50">
                    <input type="text" class="form-control" placeholder="Otto">
                </label>
            </td>
            <td class="d-flex flex-row align-items-baseline">
                <button type="button" class="btn btn-primary me-3">修改</button>
                <button type="button" class="btn btn-info me-3" data-bs-toggle="modal"
                        data-bs-target="#productPreviewModal">预览图
                </button>
                <button type="button" class="btn btn-danger">删除</button>
            </td>
        </tr>
        </tbody>
    </table>
</div>


<div class="modal fade" tabindex="-1" id="exampleModal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">新建产品</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body d-flex flex-column align-items-center">
                <div class="input-group mb-3">
                    <span class="input-group-text">商品名</span>
                    <input type="text" class="form-control" id="input1">
                </div>
                <div class="mb-3">
                    <select class="form-select me-3" aria-label="Default select example" id="modal-selector">
                    </select>
                </div>
                <div class="input-group mb-3">
                    <span class="input-group-text">中杯价格</span>
                    <input type="text" class="form-control" id="input2">
                </div>
                <div class="input-group mb-3">
                    <span class="input-group-text">大杯价格</span>
                    <input type="text" class="form-control" id="input3">
                </div>
                <!--                <div class="input-group mb-3">-->
                <!--                    <span class="input-group-text" id="input4">折扣</span>-->
                <!--                    <input type="text" class="form-control" aria-describedby="input4">-->
                <!--                </div>-->
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary me-3" onclick="productCreate()">创建</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" tabindex="-1" id="productPreviewModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">上传商品预览图</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body d-flex flex-column align-items-center p-lg-5">
                <img class="avatar-preview shadow-sm mb-5" src="img/camera.png" width="130" height="130" id="preview">

                <form action="http://127.0.0.1:8080/api/upload" enctype="multipart/form-data">
                    <div class="input-group mb-3 w-100">
                        <label class="input-group-text" for="inputFile">上传</label>
                        <input type="file" class="form-control" name="file" id="inputFile">
                    </div>
                </form>

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" id="save">保存</button>
            </div>
        </div>
    </div>
</div>


<script src="js/general.js"></script>
<script src="js/product.js"></script>
<script>
    initProductSorts();
    initProducts();
    initModal();
</script>
</body>
</html>
